//
//  QuanlitytopicDetilViewController.m
//  MyProject
//
//  Created by dllo on 15/10/30.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "QuanlitytopicDetilViewController.h"
#import "QunalityDetaileTableViewCell.h"
#import "QuanlityToppicWebviewViewController.h"
#import <UIImageView+WebCache.h>
@interface QuanlitytopicDetilViewController () <UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) UITableView *tableView;
@end

@implementation QuanlitytopicDetilViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"精品";
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height - 49) style:UITableViewStylePlain];
    [self.view addSubview:self.tableView];
    self.tableView.delegate = self;
    self.tableView.dataSource =self;
    
    self.tableView.showsVerticalScrollIndicator = NO;
    
    [self.tableView registerClass:[QunalityDetaileTableViewCell class] forCellReuseIdentifier:@"detai"];
    
}

- (void)viewWillAppear:(BOOL)animated
{
        self.tabBarController.tabBar.hidden = NO;
    if (![[NSUserDefaults standardUserDefaults]boolForKey:@"isWhite"]) {
        self.tableView.backgroundColor = [UIColor grayColor];
        self.navigationController.navigationBar.barTintColor = [UIColor blackColor];
        
    }else
    {
        self.tableView.backgroundColor = [UIColor whiteColor];
        self.navigationController.navigationBar.barTintColor = [UIColor redColor];
     }
    [self.tableView reloadData];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 520;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    QunalityDetaileTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"detai"];
    
    
    QunalityGoods *goods = self.goods;
    cell.backgroundColor = [UIColor clearColor];
    cell.number.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@.png", goods.number]];
    cell.title.text = goods.title;
    cell.desc.text = goods.desc;
    [cell.pic sd_setImageWithURL:[NSURL URLWithString:[[goods.pic objectAtIndex:0] objectForKey:@"pic"]] placeholderImage:[UIImage imageNamed:@"lovebeijing.png"]];
    cell.price.text = [NSString stringWithFormat:@"￥%@", goods.price];
    

    if (![[NSUserDefaults standardUserDefaults]boolForKey:@"isWhite"]) {
        cell.title.textColor = [UIColor whiteColor];
        cell.desc.textColor = [UIColor whiteColor];
        cell.price.textColor = [UIColor whiteColor];

    }else
    {
        cell.title.textColor = [UIColor blackColor];
        cell.desc.textColor = [UIColor grayColor];
        cell.price.textColor = [UIColor grayColor];

    }
    
    
    return cell;

}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    QuanlityToppicWebviewViewController *web = [[QuanlityToppicWebviewViewController alloc] init];
    [self.navigationController pushViewController:web animated:YES];
    web.goods = self.goods;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
